package client_gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import client_controllers.CustomerServiceController;
import client_controllers.EmployeeLoginController;
import net.miginfocom.swing.MigLayout;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;

public class CustomerServiceGUI extends JFrame {
	/**
	 * @class CustomerServiceGUI is used by customer service employees to add new customers manual.
	 */

	private JPanel contentPane;
	private JTextField cid;
	private JTextField cname;
	private JTextField cage;
	private JLabel lblCustomerPhone;
	private JTextField cphone;
	private JLabel lblCustomerArea;
	private JComboBox area;
	private JButton btnSubmit;
	private JButton btnLogout;
	private JLabel Error;
	

	public CustomerServiceGUI(EmployeeLoginController elc) {
		this.setVisible(true);
		this.setTitle("Customer Service");
		setBounds(100, 100, 450, 300);
		setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new MigLayout("", "[][][][][][][][][grow]", "[][][][][][][][]"));
		
		Error = new JLabel("error");
		contentPane.add(Error, "cell 1 0 2 1");
		Error.setVisible(false);
		
		JLabel lblCustomerId = new JLabel("Customer id:");
		contentPane.add(lblCustomerId, "cell 0 1,alignx trailing");
		
		cid = new JTextField();
		contentPane.add(cid, "cell 1 1 2 1,growx");
		cid.setColumns(10);
		
		JLabel lblCustomerName = new JLabel("Customer name:");
		contentPane.add(lblCustomerName, "cell 0 2,alignx trailing");
		
		cname = new JTextField();
		contentPane.add(cname, "cell 1 2 2 1,growx");
		cname.setColumns(10);
		
		JLabel lblCustomerAge = new JLabel("Customer age:");
		contentPane.add(lblCustomerAge, "cell 0 3,alignx trailing");
		
		cage = new JTextField();
		contentPane.add(cage, "cell 1 3 2 1,growx");
		cage.setColumns(10);
		
		lblCustomerPhone = new JLabel("Customer phone:");
		contentPane.add(lblCustomerPhone, "cell 0 4,alignx trailing");
		
		cphone = new JTextField();
		contentPane.add(cphone, "cell 1 4 2 1,growx");
		cphone.setColumns(10);
		
		lblCustomerArea = new JLabel("Customer area:");
		contentPane.add(lblCustomerArea, "cell 0 5,alignx trailing");
		
		area = new JComboBox();
		contentPane.add(area, "cell 1 5 2 1,growx");
		
		btnSubmit = new JButton("Submit");
		contentPane.add(btnSubmit, "cell 1 7");
		
		btnLogout = new JButton("Logout");
		contentPane.add(btnLogout, "cell 2 7");
		 CustomerServiceController csc = new CustomerServiceController(this,elc);
		
	}

	public JComboBox getArea() {
		return area;
	}

	public void setArea(JComboBox area) {
		this.area = area;
	}

	public int get_tf_id() {
		return Integer.parseInt(this.cid.getText());
	}

	public String get_tf_name() {
		return cname.getText();
	}

	public int get_tf_age() {
		return Integer.parseInt(this.cage.getText());
	}


	public String get_tf_phone() {
		return cphone.getText();
	}

	public JLabel getError() {
		return Error;
	}

	public void setError(JLabel error) {
		Error = error;
	}
	
	public void setsubmitlis(ActionListener lis){
		this.btnSubmit.addActionListener(lis);
	}
	public void setlogoutlis(ActionListener lis){
		this.btnLogout.addActionListener(lis);
	}
	public void setexittlis(WindowListener lis){
		this.addWindowListener(lis);
	}
	
	

}
